home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_gimp.idb / usr / freeware / share / gimp / scripts / alien-glow-button.scm.z / alien-glow-button.scm
Encoding:
Text File  |  1999-07-21  |  5.1 KB  |  175 lines

  1. ; The GIMP -- an image manipulation program
  2. ; Copyright (C) 1995 Spencer Kimball and Peter Mattis
  3. ; Alien Glow themed button
  4. ; Copyright (c) 1997 Adrian Likins
  5. ; aklikins@eos.ncsu.edu
  6. ;
  7. ; based on code from Frederico Mena Quintero (Quartic)
  8. ; federico@nuclecu.unam.mx
  9. ;
  10. ; This program is free software; you can redistribute it and/or modify
  11. ; it under the terms of the GNU General Public License as published by
  12. ; the Free Software Foundation; either version 2 of the License, or
  13. ; (at your option) any later version.
  14. ; This program is distributed in the hope that it will be useful,
  15. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17. ; GNU General Public License for more details.
  18. ; You should have received a copy of the GNU General Public License
  19. ; along with this program; if not, write to the Free Software
  20. ; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  
  22.  
  23. (define (text-width extents)
  24.   (car extents))
  25.  
  26. (define (text-height extents)
  27.   (cadr extents))
  28.  
  29. (define (text-ascent extents)
  30.   (caddr extents))
  31.  
  32. (define (text-descent extents)
  33.   (cadr (cddr extents)))
  34.  
  35. (define (blend-bumpmap img drawable x1 y1 x2 y2)
  36.   (gimp-blend img
  37.           drawable
  38.           FG-BG-RGB
  39.           DARKEN-ONLY
  40.           LINEAR
  41.           100
  42.           0
  43.           REPEAT-NONE
  44.           FALSE
  45.           0
  46.           0
  47.           x1
  48.           y1
  49.           x2
  50.           y2))
  51.  
  52. (define (script-fu-alien-glow-button text
  53.                 size
  54.                 foundry
  55.                 family
  56.                 weight
  57.                 slant
  58.                 set-width
  59.                 spacing
  60.                 text-color
  61.                 glow-color
  62.                 bg-color
  63.                 padding
  64.                 glow-radius
  65.                 flatten)
  66.   (let* ((old-fg-color (car (gimp-palette-get-foreground)))
  67.      (old-bg-color (car (gimp-palette-get-background)))
  68.      (text-extents (gimp-text-get-extents text
  69.                           size
  70.                           PIXELS
  71.                           foundry
  72.                           family
  73.                           weight
  74.                           slant
  75.                           set-width
  76.                           spacing))
  77.      (ascent (text-ascent text-extents))
  78.      (descent (text-descent text-extents))
  79.      
  80.      (img-width (+ (* 2  padding)
  81.                (- (text-width text-extents)
  82.               (text-width (gimp-text-get-extents " "
  83.                                  size
  84.                                  PIXELS
  85.                                  foundry
  86.                                  family
  87.                                  weight
  88.                                  slant
  89.                                  set-width
  90.                                  spacing)))))
  91.      (img-height (+ (* 2 padding)
  92.             (+ ascent descent)))
  93.      (layer-height img-height)
  94.      (layer-width img-width)
  95.      (img-width (+ img-width glow-radius))
  96.      (img-height (+ img-height glow-radius))
  97.      (img (car (gimp-image-new  img-width   img-height  RGB)))
  98.      (bg-layer (car (gimp-layer-new img img-width img-height RGBA_IMAGE "Background" 100 NORMAL)))
  99.      (glow-layer (car (gimp-layer-new img img-width img-height RGBA_IMAGE "Glow" 100 NORMAL)))
  100.      (button-layer (car (gimp-layer-new img layer-width layer-height RGBA_IMAGE "Button" 100 NORMAL))))
  101.  
  102.     (gimp-image-disable-undo img)
  103.  
  104.     ; Create bumpmap layer
  105.     
  106.     (gimp-image-add-layer img bg-layer -1)
  107.     (gimp-palette-set-foreground '(0 0 0))
  108.     (gimp-palette-set-background bg-color)
  109.     (gimp-edit-fill img bg-layer)
  110.     (gimp-image-add-layer img glow-layer -1)
  111.  
  112.     ; Create text layer
  113.  
  114.     (gimp-image-add-layer img button-layer -1)
  115.     (gimp-layer-set-offsets button-layer (/ glow-radius 2) (/ glow-radius 2))
  116.     (gimp-selection-none img)
  117.     (gimp-rect-select img 0 0 img-width img-height REPLACE FALSE 0)
  118.     (gimp-palette-set-foreground '(100 100 100))
  119.     (gimp-palette-set-background '(0 0 0))
  120.     (gimp-blend img button-layer FG-BG-RGB NORMAL SHAPEBURST-ANGULAR 100 0 REPEAT-NONE FALSE 0 0 0 0 img-height img-width)
  121.     (gimp-edit-clear img glow-layer)
  122.     (gimp-rect-select img (/ glow-radius 4) (/ glow-radius 4) (- img-width (/ glow-radius 2)) (- img-height (/ glow-radius 2)) REPLACE FALSE 0 )
  123.     (gimp-palette-set-background glow-color)
  124.     (gimp-edit-fill img glow-layer)
  125.     (gimp-selection-none img)
  126.     (plug-in-gauss-rle 1 img glow-layer glow-radius TRUE TRUE)
  127.     (gimp-palette-set-foreground text-color)
  128.     (let ((textl (car (gimp-text
  129.                img -1 0 0 text 0 TRUE size PIXELS foundry family weight slant set-width spacing))))
  130.       (gimp-layer-set-offsets textl
  131.                   (+  padding (/ glow-radius 2))
  132.                   (+ (+ padding descent) (/ glow-radius 2))))
  133.     ; Done
  134.     (gimp-selection-none img)
  135.     (gimp-palette-set-foreground old-fg-color)
  136.     (gimp-palette-set-background old-bg-color)
  137.     (gimp-image-enable-undo img)
  138.     (if (= flatten TRUE)
  139.     (gimp-image-flatten img))
  140.     (gimp-display-new img)))
  141.  
  142. ; Register!
  143.  
  144. (script-fu-register "script-fu-alien-glow-button"
  145.             "<Toolbox>/Xtns/Script-Fu/Web page themes/Alien Glow/Button"
  146.             "Button with an eerie glow"
  147.             "Adrian Likins"
  148.             "Adrian Likins"
  149.             "July 1997"
  150.             ""
  151.             SF-VALUE "Text" "\"Hello world!\""
  152.             SF-VALUE "Size" "22"
  153.             SF-VALUE "Foundry" "\"*\""
  154.             SF-VALUE "Family" "\"futura_poster\""
  155.             SF-VALUE "Weight" "\"*\""
  156.             SF-VALUE "Slant" "\"*\""
  157.             SF-VALUE "Set width" "\"*\""
  158.             SF-VALUE "Spacing" "\"*\""
  159.             SF-COLOR "Text color" '(0 0 0)
  160.             SF-COLOR "Glow Color" '(63 252 0)
  161.             SF-COLOR "Background Color" '(0 0 0)
  162.             SF-VALUE "Padding" "6"
  163.             SF-VALUE "Glow Radius" "10"
  164.             SF-TOGGLE "Flatten Image?" TRUE)
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.